<?php
add_action( 'after_setup_theme', 'realestate_setup_theme' );
if ( ! function_exists( 'realestate_setup_theme' ) ){
	function realestate_setup_theme(){
		global $themename, $shortname;
		$themename = "RealEstate";
		$shortname = "realestate";

		require_once(TEMPLATEPATH . '/epanel/custom_functions.php');

		require_once(TEMPLATEPATH . '/includes/functions/comments.php');

		require_once(TEMPLATEPATH . '/includes/functions/sidebars.php');

		load_theme_textdomain('RealEstate', get_template_directory().'/lang');

		require_once(TEMPLATEPATH . '/epanel/options_realestate.php');

		require_once(TEMPLATEPATH . '/epanel/core_functions.php');

		require_once(TEMPLATEPATH . '/epanel/post_thumbnails_realestate.php');
		
		include(TEMPLATEPATH . '/includes/widgets.php');
		
		require_once(TEMPLATEPATH . '/includes/functions/additional_functions.php');
	}
}

add_action('wp_head','realestate_portfolio_page_template_additional_styles',100);
function realestate_portfolio_page_template_additional_styles(){ ?>
	<style type="text/css">
		#realestate_page_template_portfolio_gallery { margin-left: -15px; }
		.realestate_page_template_portfolio_item { margin-left: 21px; }
		.realestate_portfolio_small { margin-left: -40px !important; }
		.realestate_portfolio_small .realestate_page_template_portfolio_item { margin-left: 38px !important; }
		.realestate_portfolio_large { margin-left: -8px !important; }
		.realestate_portfolio_large .realestate_page_template_portfolio_item { margin-left: 6px !important; }
	</style>
<?php }

function register_main_menus() {
	register_nav_menus(
		array(
			'primary-menu' => __( 'Primary Menu' ),
			'secondary-menu' => __( 'Secondary Menu' )
		)
	);
}
if (function_exists('register_nav_menus')) add_action( 'init', 'register_main_menus' );

if ( ! function_exists( 'realestate_list_pings' ) ){
	function realestate_list_pings($comment, $args, $depth) {
		$GLOBALS['comment'] = $comment; ?>
		<li id="comment-<?php comment_ID(); ?>"><?php comment_author_link(); ?> - <?php comment_excerpt(); ?>
	<?php }
}

add_action('template_redirect','check_listing');
function check_listing() {
	if (isset($_REQUEST["option-listing"])) { 
		$category_link = get_category_link( $_REQUEST["option-listing"] );
		wp_redirect($category_link);
	}
}

add_filter('body_class','realestate_additional_body_class');
function realestate_additional_body_class($classes) {
	if ( !is_home()) $classes[] = 'index';
	return $classes;
} ?>